﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoVanHocTapData.Entities;
using CoVanHocTapData.Interface;

namespace CoVanHocTapData.Concretes
{
    public class HanDaoTaoRepository
    {
        #region property
        static DangKyPhuEntities entities = new DangKyPhuEntities();
        #endregion

        #region constructor
        public HanDaoTaoRepository()
        {

        }
        #endregion

        public static IQueryable<HanDaoTao> LayHanDaoTaoTheoNganhHe(string nganhID, string heDaoTaoID)
        {
            return (from m in entities.HanDaoTaos
                    where m.NganhID.Equals(nganhID)
                    && m.HeDaoTaoID.Equals(heDaoTaoID)
                    select m);
        }

        public int LaySoNamHocTheoMaSV(string maSV)
        {
            string maNganh = new NganhDaoTaoRepository().LayMaNganhTuMaSV(maSV);
            string maHeDaoTao = new HeDaoTaoRepository().LayMaHeDaoTaoTuMaSV(maSV);
            int soNam = int.Parse(LayHanDaoTaoTheoNganhHe(maNganh, maHeDaoTao).FirstOrDefault().SoNamHoc.ToString());
            return soNam;
        }


    }
}
